using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace MvcApplication4.Models.Mapping
{
    public class tb_FuncionarioMap : EntityTypeConfiguration<tb_Funcionario>
    {
        public tb_FuncionarioMap()
        {
            // Primary Key
            this.HasKey(t => t.ID_Funcionario);

            // Properties
            this.Property(t => t.Nome_Funcionario)
                .IsRequired()
                .HasMaxLength(200);

            this.Property(t => t.CPF)
                .IsRequired()
                .HasMaxLength(20);

            this.Property(t => t.Login_Fun)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.Senha)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.Telefone)
                .IsRequired()
                .HasMaxLength(30);

            this.Property(t => t.Email)
                .HasMaxLength(100);

            // Table & Column Mappings
            this.ToTable("tb_Funcionario");
            this.Property(t => t.ID_Funcionario).HasColumnName("ID_Funcionario");
            this.Property(t => t.ID_UBS).HasColumnName("ID_UBS");
            this.Property(t => t.Nome_Funcionario).HasColumnName("Nome_Funcionario");
            this.Property(t => t.CPF).HasColumnName("CPF");
            this.Property(t => t.Login_Fun).HasColumnName("Login_Fun");
            this.Property(t => t.Senha).HasColumnName("Senha");
            this.Property(t => t.Telefone).HasColumnName("Telefone");
            this.Property(t => t.Email).HasColumnName("Email");

            // Relationships
            this.HasRequired(t => t.tb_UBS)
                .WithMany(t => t.tb_Funcionario)
                .HasForeignKey(d => d.ID_UBS);

        }
    }
}
